<!--
 * @Description: h5页面生成器 
 * @Autor: WangYuan
 * @Date: 2021-03-29 10:58:42
 * @LastEditors: WangYuan
 * @LastEditTime: 2021-04-20 15:45:14
-->
<template>
  <div style="border-left: 1px solid #ddd;">
    <iframe class="h5-generator" id="iframe" :src="url"></iframe>
  </div>
</template>

<script>
import { getToken } from '@/utils/auth'
import { mapGetters } from 'vuex'

export default {
  name: 'h5-generator',
  computed: {
    ...mapGetters(['dict']),
    linkTypeString () {
      // console.log(this.dict.link_type);
      // console.log(JSON.stringify(this.dict.link_type));
      return JSON.stringify(this.dict.link_type)
    },
    url () {
      return `${
        import.meta.env.VITE_APP_H5_GENERATOR_API
      }?token=${getToken()}&linkType=${this.linkTypeString}`
    }
  },
  methods: {
    call () {
      const iFrame = document.getElementById('iframe')
      iFrame.onload = function () {
        iFrame.contentWindow.postMessage(
          '父页面发送的消息',
          'http://b.index.com'
        )
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.h5-generator {
  width: 100%;
  height: calc(100vh - 89px);
  border: 0 !important;
  border-left: 1px solid #ccc;
}
</style>
